<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-adx__meituanorder}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item label="广告位ID">
          <el-input v-model="dataForm.sid" placeholder="广告位ID" clearable></el-input>
        </el-form-item>

        <el-form-item label="订单状态">
        <el-select v-model="dataForm.status" placeholder="选择运营人员" filterable clearable>
            <el-option
              v-for="status in statusOptions"
              :key="status.value"
              :label="status.label"
              :value="status.value"
            ></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="支付起始时间">
          <el-date-picker v-model="dataForm.stime" value-format="yyyy-MM-dd" type="date"
            placeholder="起始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="支付结束时间">
          <el-date-picker v-model="dataForm.etime" value-format="yyyy-MM-dd" type="date"
            placeholder="结束时间">
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('adx:meituanorder:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('adx:meituanorder:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="主键ID" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="smstitle" label="订单标题" header-align="center" align="center"></el-table-column>
        <el-table-column prop="quantity" label="订单数量" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="paytime" label="支付时间" header-align="center" align="center"  :formatter="formatDate"  ></el-table-column>></el-table-column>
        <!-- <el-table-column prop="total" label="" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="status" label="订单状态" header-align="center" align="center">
          <template slot-scope="scope">
            {{ $getDictLabel("mtOrderList", scope.row.status) }}
          </template>
        </el-table-column>
        <el-table-column prop="actId" label="活动ID" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="ordertime" label="" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="payPrice" label="支付金额" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="productId" label="" header-align="center" align="center"></el-table-column> -->
        <el-table-column :show-overflow-tooltip='true' prop="productName" label="商品名称" header-align="center" align="center"></el-table-column>
        <el-table-column prop="businessLine" label="订单类型" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="subBusinessLine" label="子订单类型" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="tradeTypes" label="转化类型" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="createTime" label="创建时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updateTime" label="更新时间" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="orderId" label="订单ID" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="extend" label="扩展字段，原始报文" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="handType" label="回传类型" header-align="center" align="center">
          <template slot-scope="scope">
            {{ $getDictLabel("mtHandType", scope.row.handType) }}
          </template>
        </el-table-column>
        <el-table-column prop="appkey" label="媒体ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="sid" label="广告位ID" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('adx:meituanorder:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('adx:meituanorder:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './meituanorder-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/adx/meituanorder/page',
        getDataListIsPage: true,
        exportURL: '/adx/meituanorder/export',
        deleteURL: '/adx/meituanorder',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      },
      statusOptions: [
        { value: '2', label: '已付款' },
        { value: '3', label: '完成' },
        { value: '4', label: '取消' },
        { value: '5', label: '风控' },
        { value: '6', label: '结算' },
      ],
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    formatDate(row, column, timestamp) {
    if (!timestamp) return '-'; // 处理空值
    const date = new Date(timestamp * 1000); // 时间戳转毫秒
    // 格式化为 yyyy-MM-dd HH:mm:ss
    return date.toLocaleString('zh-CN', { 
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit',
      hour12: false // 24小时制
    }).replace(/\//g, '-'); // 将斜杠替换为短横
  }
  }
}
</script>
